package com.lvkerry.orderfood.service.impl;

import com.lvkerry.orderfood.api.ApiBean;
import com.lvkerry.orderfood.entity.MenuEntity;
import com.lvkerry.orderfood.repository.MenuRepository;
import com.lvkerry.orderfood.service.MenuService;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.lvkerry.orderfood.global.ConstCodeKt.API_SUCCESS;


/**
 * @author Kerry
 */

@Service
public class MenuServiceImpl implements MenuService {

    private final MenuRepository menuRepository;

    @Autowired
    public MenuServiceImpl(MenuRepository menuRepository) {
        this.menuRepository = menuRepository;
    }


    @Override
    public ApiBean addMenu(@NotNull MenuEntity menuEntity) {
        return null;
    }

    @Override
    public ApiBean deleteMenuById(@NotNull Long id) {
        return null;
    }

    @Override
    public ApiBean updateMenu(@NotNull MenuEntity menuEntity) {
        return null;
    }

    @Override
    public ApiBean findAllMenu() {
        List<MenuEntity> all = menuRepository.findAll();
        return new ApiBean.Builder().setStatus(API_SUCCESS).setData(all).build();
    }

    @Override
    public ApiBean findMenuDetail(Long menuId) {

        MenuEntity one = menuRepository.findOne(menuId);

        return new ApiBean.Builder().setStatus(API_SUCCESS).setData(one).build();
    }
}
